import * as gitdb from 'gitee-simple-db/src/index'
import { doMakeSecrets } from './make_secrets';
import { BasicInfoItem } from './table_data_model';
const BasicInfo = new gitdb.WrapIssueForTable("sample_db", {transBodyToJSON: false})

const AddOneItem = (data: BasicInfoItem): Promise<any> => {
    console.log("add data:", data)
    console.log(JSON.stringify(data))
    let secretInfo = doMakeSecrets().encrypt(JSON.stringify(data));
    return BasicInfo.addOneData(secretInfo)
}
const UpdateOneItem = (data: BasicInfoItem): Promise<any> => {
    console.log("update data:", data)
    console.log(JSON.stringify(data))
    let secretInfo = doMakeSecrets().encrypt(JSON.stringify(data));
    return BasicInfo.updateOneData(secretInfo, <number>data.id)
}
export {
    AddOneItem,
    BasicInfo,
    UpdateOneItem,
};